// components/hint.js
const app = getApp()
const util = require('../../utils/util.js')
import {
  UserModel
} from '../../models/user.js'
let user = new UserModel()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    loginshow: {
      type: Boolean,
      value: true
    },
    quxiao: {
      type: Boolean,
      value: false
    },
    insqfk: {
      type: Boolean,
      value: false
    },
    fkText: {
      type:String
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    //授权保存用户信息
    bindGetUserInfo: function(e) {
      console.log(wx.getStorageSync('userInfo').userName)
      this.setData({
        fkText: !wx.getStorageSync('userInfo').userName ? '您已经赚取200金币' : '您已授权成功,快去赚更多金币吧!'
      })
      if (e.detail.userInfo) {
        user.saveUserInfo(e.detail.userInfo);
        this.setData({
          loginshow: false,
          insqfk: true
        })
      }
    },
    qixiao: function() {
      this.setData({
        loginshow: false
      })
    },
    bindToTask: function() {
      this.setData({
        insqfk: false
      })
      wx.switchTab({
        url: '/pages/task/task',
      })
    }
  }

})